home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / cenvid9.zip / RUNTIME.BAT < prev    next >
DOS Batch File  |  1994-03-04  |  2KB  |  57 lines

  1. @echo off
  2. REM *********************************************************
  3. REM *** RunTime.bat - Execute commands at specified time. ***
  4. REM *** ver.1                                             ***
  5. REM *********************************************************
  6.  
  7. ECHO Command: %2 %3 %4 %5 %6 %7 %8 %9
  8. CEnvi %0.bat %1
  9. GOTO CENVI_EXIT
  10.  
  11. main(argc,argv)
  12. {
  13.    if ( argc < 2  ||  2 != sscanf(argv[1],"%d:%d",RunHour,RunMinute)
  14.      || RunHour < 0  ||  23 < RunHour
  15.      || RunMinute < 0  ||  59 < RunMinute ) {
  16.       Instructions();
  17.    } else {
  18.       printf("Scheduled time: %02d:%02d:00\n",RunHour,RunMinute);
  19.       // Loop here forever until RunHour:RunMinute comes along, then exit
  20.       DisplayedSecond = -1; // force current time to print
  21.       do {
  22.          GetCurrentTime(CurrentHour,CurrentMinute,CurrentSecond);
  23.          if ( CurrentSecond != DisplayedSecond )
  24.             printf("\rCurrent Time:   %02d:%02d:%02d",
  25.                    CurrentHour,CurrentMinute,DisplayedSecond=CurrentSecond);
  26.       } while ( CurrentHour != RunHour  ||  CurrentMinute != RunMinute );
  27.       printf("\n");
  28.    }
  29. }
  30.  
  31. GetCurrentTime(hour,minute,second)
  32. {
  33.    now = localtime(time());
  34.    hour = now.tm_hour;
  35.    minute = now.tm_min;
  36.    second = now.tm_sec;
  37. }
  38.  
  39. Instructions()
  40. {
  41.    printf("\n");
  42.    printf("RunTime - Perform a command, with up to 7 parameters, at a specified time.\n");
  43.    printf("\n");
  44.    printf("SYNTAX: RunTime <hour>:<minute> [Command] [parm1] [parm2] [etc...]\n");
  45.    printf("\n");
  46.    printf("Where: hour   - hour of day (in 24-hour format) to run command; range 0 - 23\n");
  47.    printf("       minute - minute of hour to run command: range 0 - 59\n");
  48.    printf("\n");
  49.    printf("Examples: RunTime 14:30 chkdsk c: /f   - run chkdsk at 2:30 PM\n");
  50.    printf("          RunTime 0:00                 - pause computer until midnight\n");
  51.    printf("\n");
  52. }
  53.  
  54. :CENVI_EXIT
  55. ECHO %2 %3 %4 %5 %6 %7 %8 %9
  56. %2 %3 %4 %5 %6 %7 %8 %9
  57.